<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="java.util.*"%>
<%@ page import="com.qingke.stockdata.model.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DecimalFormat"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>轻课股票数据分析系统</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="css/metisMenu.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/sb-admin-2.css" rel="stylesheet">
<!-- Morris Charts CSS -->
<link href="css/morris.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div id="wrapper">
		<!-- Navigation -->
		<nav class="navbar navbar-default navbar-static-top" role="navigation"
			style="margin-bottom: 0">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target=".navbar-collapse">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="index.html">轻课网股票数据分析系统</a>
			</div>
			<!-- /.navbar-header -->

			<ul class="nav navbar-top-links navbar-right">

				<!-- /.dropdown -->
				<li class="dropdown"><a class="dropdown-toggle"
					data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i>
						<i class="fa fa-caret-down"></i>
				</a>
					<ul class="dropdown-menu dropdown-user">
						<li><a href="#"><i class="fa fa-user fa-fw"></i> 修改密码</a></li>
						<li class="divider"></li>
						<li><a href="login"><i class="fa fa-sign-out fa-fw"></i>
								退出</a></li>
					</ul> <!-- /.dropdown-user --></li>
				<!-- /.dropdown -->
			</ul>
			<!-- /.navbar-top-links -->

			<div class="navbar-default sidebar" role="navigation">
				<div class="sidebar-nav navbar-collapse">
					<ul class="nav" id="side-menu">
						<li class="sidebar-search">
							<form action="detail">
								<div class="input-group custom-search-form">
									<input type="text" class="form-control"
										placeholder="输入代码, 如sz000001" name="code" /> <span
										class="input-group-btn">
										<button class="btn btn-default" type="submit">添加</button>
									</span>
								</div>
							</form>
						</li>
						<li><a href="index.html"><i class="fa fa-heart-o fa-fw"></i>我的关注</a>
						</li>
						<li><a href="index.html"><i
								class="fa fa-thumbs-o-up fa-fw"></i>今日最佳</a></li>

						<li><a href="index.html"><i
								class="fa fa-thumbs-o-down fa-fw"></i>今日最差</a></li>
					</ul>
				</div>
				<!-- /.sidebar-collapse -->
			</div>
			<!-- /.navbar-static-side -->
		</nav>

		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">自选股列表</h1>
				</div>
				<!-- /.col-lg-12 -->
			</div>
			<!-- /.row -->
			<div class="row">
				<div class="col-lg-12">
					<div class="panel panel-default">

						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive">
								<table class="table">
									<thead>
										<tr>
											<th>#</th>
											<th>名称</th>
											<th>最新价格</th>
											<th>更新时间</th>
											<th>历史最低</th>
											<th>历史最高</th>
											<th>今日涨跌</th>
										</tr>
									</thead>
									<%!
										String ratioOf(double open, double close) {
											DecimalFormat df = new DecimalFormat("#0.00");
											String ratio = "";
											if ((open-close) < 0) {
												ratio += "-";
												double result = (open - close) / open * 100;
												ratio += df.format(result);
											} else {
												double result = (open - close) / open* 100;
												ratio += df.format(result);
											}
											ratio += "%";
											return ratio;
									}
									%>
									<%
										int count = 1;
										List<Stock> stocks = (List<Stock>)request.getAttribute("allstocks");
										SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
										for(Stock s:stocks){
									%>
									<tbody>
										<tr class="info">
											<td><%=count%></td>
											<td><a href="#"><%=s.getName()%></a></td>
											<td><%="在线获取"%></td>
											<td><%=sdf.format(new Date()) %></td>
											<td><%=s.getHisotryLow() %></td>
											<td><%=s.getHistoryHigh()%></td>
											<td><%=ratioOf(s.getHistoryHigh(),s.getHisotryLow()) %></td>
										</tr>
									</tbody>
									<%
										count++;
										}
									%>
								</table>
							</div>
							<!-- /.table-responsive -->
						</div>
						<!-- /.panel-body -->
					</div>
					<!-- /.panel -->
				</div>

			</div>

			<!-- /.row -->
		</div>
		<!-- /#page-wrapper -->

	</div>
	<!-- /#wrapper -->

	<!-- jQuery -->
	<script src="js/jquery.min.js"></script>

	<!-- Bootstrap Core JavaScript -->
	<script src="js/bootstrap.min.js"></script>

	<!-- Metis Menu Plugin JavaScript -->
	<script src="js/metisMenu.min.js"></script>

	<!-- Morris Charts JavaScript -->
	<script src="js/raphael.min.js"></script>
	<script src="js/morris.min.js"></script>
	<script src="js/morris-data.js"></script>

	<!-- Custom Theme JavaScript -->
	<script src="js/sb-admin-2.js"></script>

</body>

</html>
